package cn.wenhe9.yygh.sms.receiver;

import cn.wenhe9.yygh.model.vo.sms.SmsVo;
import cn.wenhe9.yygh.sms.service.SmsService;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author DuJinliang
 * 2022/4/7
 */
@Component
@EnableBinding(Sink.class)
public class SmsReceiver {

    @Resource
    private SmsService smsService;

    @StreamListener(Sink.INPUT)
    public void sendSms(Message<SmsVo> message){
        smsService.send(message.getPayload());
    }
}
